<html>
	<head>
		<link rel = "stylesheet" href = "style.css">
		<script src="jquery-1.11.0.js"></script>
		<script>
		f
			function showSchedulePopUp(obj){
				var x=obj.offsetLeft;
				var y=obj.offsetTop+20;
				$("#divSchedule").offset({top:y,left:y});
				$("#divSchedule").fadeIn( "slow");
			}
			
			function hideSchedulePopUp(){
				$("#divSchedule").fadeOut( "slow");
			}
		</script>

	</head>
	<body>

<?php	
			// include_once ("community.php");
			// $obj= new community();
			// $obj->connect();
			
			
			
			// $community_id=0;
			// if(!isset($_REQUEST['community_id'])){
			// 	echo "no id";
			// }
			// $community_id=$_REQUEST['community_id'];
			
		
			// $obj->search_community($community_id);
			// $row=$obj->fetch();
?>
			<table>
			<tr>
				<td colspan="2" id="pageheader">
					HEALTH INFORMATION SYSTEMS
				</td>
			</tr>
			<tr>
				<td id="mainnav">
					<div class="menuitem"><a href = "community_lists.php">Community</a></div>
					<div class="menuitem">Subdistricts</div>
					<div class="menuitem"><span class="menuitem" ><a href = "community_add.php" target="_blank">Add to the community table</a></span></div>
					
					<div class="menuitem"></div>
					<div class="menuitem"></div>
					<div class="menuitem"></div>
				
				</td>
				<td id="content">
				<!--
					<div id="divPageMenu">
						<span class="menuitem" >User accounts</span>
						<input type="text" id="txtSearch">
						<span class="menuitem">search</span>		
					</div>
					<div id="divStatus" class="status">
						Welcome to the Health Information System-->
					</div>
					<div id="divContent">
						<table class="reportTable" width="100%">
							<tr class="header" >
								<td>community Details</td>
								<td></td>
							</tr>
							
<!-- 				<form action="communityedit.php" method="GET">
			<table>
				
				<tr><td>Population: </td> <td><input type="text" value="<?php //echo $row['population']?>" name="population"></td></tr>
				<tr><td>Household:</td> <td> <input type="text" value="<?php //echo $row['household']?>" name="household"></td></tr>
				<tr><td>Community Name:</td> <td> <input type="text" value="<?php //echo $row['community_name']?>" name="community_name"></td></tr>
				
			</table>
			<input type="submit" name="submit" value="Edit">
			<input type="hidden" value="<?php //echo $community_id ?>" name="community_id"> 
			<input type = "hidden" value = "<?php //echo $subdistrict_id ?>" name = "subdistrict_id"/>
			<input type="hidden" value="<?php //echo $row['latitude']?>" name="latitude">
			<input type="hidden" value="<?php //echo $row['longitude']?>"  name="longitude">
		</form> -->

				
			
<?php	
	// $community_id = 0;
	// $latitude = 0;
	// $longitude = 0;
	// $population = 0;
	// $household = 0;
	// $community_name = "";
	// $subdistrict_id = 0;
		include("community.php");
	if(!isset($_REQUEST['id'])){
		echo " no id";
		exit();
	}
	// if(isset($_REQUEST["subdistrict_id"])){
	// $subdistrict_id = $_REQUEST["subdistrict_id"];
	// }
		$cid = $_REQUEST['id'];
		$obj = new community();
		if(isset($_REQUEST['community_name'])){
			$community_name=$_REQUEST['community_name'];
			$population=$_REQUEST['population'];
			$household=$_REQUEST['household'];
			$obj->update_community($community_name,$population,$household);
		}
		
	$row = $obj -> get_community($cid);
		
?>	

<form action="communityedit.php" method="GET" onsubmit="validate()">
			<table class="tableForm" >
					<tr>
						<td class="label">Community Name: </td>
						<td class="field"><input type="text" value="<?php echo $row['community_name'] ?>" name="community_name" ></td>
					</tr>
					<tr>
						<td class="label">Population:</td> 
						<td class="field"><input type="text" value="<?php echo $row['population'] ?>" name="population" onfocus="showSchedulePopUp(this)" >
						</td>
					</tr>
					<tr>
						<td class="label">Household :</td>
						<td class="field"><input type="text" value="<?php echo $row['household'] ?>" name="household" >
						</td>
					</tr>
					<tr>
						<td class="label"></td>
						<td class="field">
							<input type="submit" value="save" name="submit" >
						</td>
					</tr>
			</table>
			<input type="hidden" value="<?php echo $cid ?>" name="id" >
		</form>
		<div id="divSchedule" class="popupMenu" onclick="hideSchedulePopUp()">
			<div> at birth</div>
			<div> 6 weeks</div>
			<div> 10 weeks</div>
		</div>
	</body>
</html>